from flask import Flask, request, send_from_directory
from flask_migrate import Migrate
from exts import db
import config
from flask import Blueprint
from models import Community_PostModel,UserModel
from blueprints.community.post_api import post_api_bp
from blueprints.community.post_query_api import post_query_bp
from blueprints.community.post_action_api import post_action_bp
from blueprints.auth_api import auth_api_bp

app = Flask(__name__)
app.config.from_object(config)

# 初始化数据库
db.init_app(app)
migrate = Migrate(app, db)

# 注册蓝图

app.register_blueprint(post_api_bp, url_prefix='/api')
app.register_blueprint(auth_api_bp,url_prefix='/api')
app.register_blueprint(post_query_bp, url_prefix='/api')
app.register_blueprint(post_action_bp, url_prefix='/api')

@app.route('/uploads/<filename>')
def uploaded_file(filename):
    return send_from_directory(app.config['UPLOAD_FOLDER'], filename)



if __name__ == '__main__':
    app.run()

